/*
 * Date          Author         Note
 * 2014.11.21    wzwz           系统运行窗口
 * 2015.05.25    wzwz           起底板使能后不能行定
 * 2015.05.27    wzwz           显示副程式页的数据
 * 2015.06.23    wzwz           报警屏蔽图标显示
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
#include <mh/common.h>
#include <mh/com.h>
#include "resource.h"
#include "func.h"
#include "mhctrlstate.h"
#include "lang.h"
#include "run.h"
#include "com.h"
#include "help.h"
#include "mhbtn.h"
#include "mhlabel.h"
#include "mhedit.h"
#include "work.h"
#include "density.h"
#include "rab.h"
#include "roll.h"
#include "switch.h"
#include "speed.h"
#include "yarn_stop.h"
#include "economy.h"
#include "sink.h"
#include "yarn_com.h"
#include "extent.h"
#include "knit_line.h"
#include "stop_line.h"
#include "yarn_check.h"
#include "yarn_exchange.h"
#include "yarn_feed.h"
#include "info.h"
#include "password.h"
#include "utf8_gb2312.h"
#include "ver.h"
#include "mac_com.h"
#include "dumu_com.h"
#include "alarm.h"
#include "dlg_ask.h"
#include "rude.h"
#include "reset.h"
#include "board_test.h"


HWND CreateMasterWindow(HWND hHosting);
void UpdateRunWarn(HWND hWnd, int errcode);

#define RESET_CTRL_WIDTH   (52)
#define RESET_CTRL_HEIGHT  (52)
#define RESET_CTRL_LEFT    (CX_EDGE_LEFT)
#define RESET_CTRL_TOP     (CY_SCREEN - CX_EDGE_LEFT - RESET_CTRL_HEIGHT)
#define RESET_CTRL_INTER   (3)

#define DUMU1_CAPTION_LEFT     RESET_CTRL_LEFT
#define DUMU1_CAPTION_TOP      RESET_CTRL_TOP - 180
#define DUMU1_CAPTION_WIDTH    70
#define DUMU1_CAPTION_HEIGHT   34
#define DUMU1_CAPTION_INTER    160 //横向间隔
#define SINK_CAPTION_INTER     130
#define DUMU1_NAME_WIDTH       40
#define SECT_RECT_WIDTH        32
#define SECT_RECT_INTER        9   //纵向间隔
#define CYCLE_RECT_WIDTH       60

#define FLW_CAPTION_LEFT       RESET_CTRL_LEFT
#define FLW_CAPTION_TOP        DUMU1_CAPTION_TOP - 194
#define FLW_CAPTION_WIDTH      59
#define FLW_CAPTION_HEIGHT     18
#define YARN_CAPTION_WIDTH     160

#define FILE_CAPTION_LEFT      RESET_CTRL_LEFT
#define FILE_CAPTION_TOP       CX_EDGE_LEFT + 8
#define FILE_CAPTION_WIDTH     70
#define FILE_CAPTION_HEIGHT    30
#define FILE_NAME_WIDTH        70
#define LINE_NAME_WIDTH        140
#define DATE_NAME_WIDTH        160
#define FILE_CAPTION_INTER     10


/*
 *
 */
void FlushRunWndEfficiency(HWND hWnd)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);
    if(data.pwnd_run)
    {
        uint t = GetKnitTime(g_knit_data);
        if(data.pwnd_run->efficiency != t)
        {
            data.pwnd_run->efficiency = t;
            char sc[128] = {0};
            uint hour = t / 3600;
            uint minite = (t - hour * 3600) / 60;
            uint second = t % 60;
            sprintf(sc, "%02u:%02u:%02u", hour, minite, second);
            HWND hTmp = GetDlgItem(hWnd, IDC_EFFICIENCY);
            SetWindowCaption(hTmp, sc);
            InvalidateRect(hTmp, NULL, TRUE);
        }
    }
}
/*
 *
 */
void FlushRunWndCycle(HWND hWnd, ushort line)
{
    HWND hWndTmp = -1;
    char sc[64] = {0};
    //cycle
    ushort economy_start = 0;
    ushort economy_end = 0;
    //cycle num
    hWndTmp = GetDlgItem(hWnd, ID_BTN_HD);
    uchar hd = GetHangDingEnable(g_knit_data);
    ushort times = 0;
    uint hd_state = GetCtrlState(hWndTmp);
    int prefix = IsPrefixKnit(g_knit_data);
    int auxcon = IsAuxConKnit(g_knit_data);
    if(prefix)
    {
        economy_start = 1;
        economy_end = GetPrefixPages(g_knit_data);
    }
    else if(auxcon)
    {
        economy_start = 1;
        economy_end = GetAuxConRows(g_knit_data);
    }
    else if(hd == HD_START || hd == HD_FORBID_MODIFY)
    {
        times = GetHangDingTimes(g_knit_data);
        ushort left_times = GetEconomyLeft(g_knit_data);
        if(hd == HD_START)
        {
            if(!hd_state)
            {
                SetCtrlState(hWndTmp, TRUE);
                InvalidateRect(hWndTmp, NULL, TRUE);
            }
        }
        ushort hd_start = GetHangDingStart(g_knit_data);
        ushort hd_end =GetHangDingEnd(g_knit_data);
        if(line >= hd_start && line <= hd_end)
        {
            economy_start = hd_start;
            economy_end = hd_end;
        }
        else
        {
            times = 0;
        }
        if(!left_times)
        {
            SetHangDingEnable(g_knit_data, HD_END);
            times = 0;
            SetCtrlState(hWndTmp, FALSE);
            InvalidateRect(hWndTmp, NULL, TRUE);
        }
    }
    else
    {
        ushort data[10][3];
        int i = 0;
        economy_start = GetEconomyStart(g_knit_data);
        economy_end = GetEconomyEnd(g_knit_data);
        GetEconomyData(g_knit_data, data, 10);
        if(economy_start)
        {
            for(i = 0;i < 10; i++)
            {
                if(data[i][1] == economy_end)
                {
                    times = data[i][2];
                }
            }
        }
        else
        {
            times = 0;
        }
        if(hd_state)
        {
            SetCtrlState(hWndTmp, FALSE);
            InvalidateRect(hWndTmp, NULL, TRUE);
        }
    }
    sprintf(sc, "%u", economy_start);
    hWndTmp = GetDlgItem(hWnd, IDC_CYCLE_START);
    SetWindowCaption(hWndTmp, sc);
    InvalidateRect(hWndTmp, NULL, TRUE);

    sprintf(sc, "%u", economy_end);
    hWndTmp = GetDlgItem(hWnd, IDC_CYCLE_END);
    SetWindowCaption(hWndTmp, sc);
    InvalidateRect(hWndTmp, NULL, TRUE);

    if(prefix)
    {
        sc[0] = 0;
        strcat(sc, GetString(708));
    }
    else if(auxcon)
    {
        sc[0] = 0;
        strcat(sc, GetString(779));
    }
    else
    {
        sprintf(sc, "%u", GetEconomyLeft(g_knit_data));
    }
    hWndTmp = GetDlgItem(hWnd, IDC_CYCLE_LEFT);
    SetWindowCaption(hWndTmp, sc);
    InvalidateRect(hWndTmp, NULL, TRUE);
    sprintf(sc, "%u", times);
    hWndTmp = GetDlgItem(hWnd, IDC_CYCLE_NUM);
    SetWindowCaption(hWndTmp, sc);
    InvalidateRect(hWndTmp, NULL, TRUE);
}
/*
 * read control page
 */
static void ReadConPage(HWND hWnd, ushort line)
{
    HWND hWndTmp = 0;
    char sc[MH_FILE_NAME_MAX_LEN] = {0};
    KNIT_PAGE con;
    KNIT_PAGE *p = (KNIT_PAGE*)GetRunPage(g_knit_data, line);
    if(p)
    {
        memcpy(&con, p, sizeof(KNIT_PAGE));
        GetPage4CamLock(g_knit_data, &con, line);
        p = &con;
    }
    //line
    hWndTmp = GetDlgItem(hWnd, IDC_LINE_FINISHED);
    sprintf(sc, "%d/%d", line, GetTotalKnitPage(g_knit_data));
    SetWindowCaption(hWndTmp, sc);
    InvalidateRect(hWndTmp, NULL, TRUE);
    //drt
    hWndTmp = GetDlgItem(hWnd, IDC_LEFT_DRT);
    SetWindowCaption(hWndTmp, line & 1 ? ">>>>>>" : "<<<<<<");
    InvalidateRect(hWndTmp, NULL, TRUE);
    if(p)
    {
        //flw line
        sprintf(sc, "%u", line & 1 ? p->flw_2B : p->flw_1B);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_BACKL_ROW);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        sprintf(sc, "%u", line & 1 ? p->flw_2F : p->flw_1F);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_FRNTL_ROW);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        sprintf(sc, "%u", line & 1 ? p->flw_1B : p->flw_2B);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_BACKR_ROW);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        sprintf(sc, "%u", line & 1 ? p->flw_1F : p->flw_2F);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_FRNTR_ROW);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //left cmd
        GetCmdString(sc, line & 1 ? p->act_2BH : p->act_1BH, TRUE);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_LEFT_CMD_BH);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetCmdString(sc, line & 1 ? p->act_2BA : p->act_1BA, FALSE);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_LEFT_CMD_BA);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetCmdString(sc, line & 1 ? p->act_2FA : p->act_1FA, FALSE);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_LEFT_CMD_FA);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetCmdString(sc, line & 1 ? p->act_2FH : p->act_1FH, TRUE);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_LEFT_CMD_FH);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //left code
        GetCodeString(sc, line & 1 ? p->code_2BH : p->code_1BH);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_LEFT_CODE_BH);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetCodeString(sc, line & 1 ? p->code_2BA : p->code_1BA);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_LEFT_CODE_BA);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetCodeString(sc, line & 1 ? p->code_2FA : p->code_1FA);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_LEFT_CODE_FA);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetCodeString(sc, line & 1 ? p->code_2FH : p->code_1FH);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_LEFT_CODE_FH);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //right cmd
        GetCmdString(sc, line & 1 ? p->act_1BH : p->act_2BH, TRUE);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_RGHT_CMD_BH);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetCmdString(sc, line & 1 ? p->act_1BA : p->act_2BA, FALSE);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_RGHT_CMD_BA);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetCmdString(sc, line & 1 ? p->act_1FA : p->act_2FA, FALSE);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_RGHT_CMD_FA);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetCmdString(sc, line & 1 ? p->act_1FH : p->act_2FH, TRUE);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_RGHT_CMD_FH);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //right code
        GetCodeString(sc, line & 1 ? p->code_1BH : p->code_2BH);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_RGHT_CODE_BH);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetCodeString(sc, line & 1 ? p->code_1BA : p->code_2BA);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_RGHT_CODE_BA);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetCodeString(sc, line & 1 ? p->code_1FA : p->code_2FA);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_RGHT_CODE_FA);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetCodeString(sc, line & 1 ? p->code_1FH : p->code_2FH);
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_RGHT_CODE_FH);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //yarn
        int yarn_1used = (p->gauze1_1 << 8) | (p->gauze1_9 & 0xFF);
        int yarn_2used = (p->gauze2_1 << 8) | (p->gauze2_9 & 0xFF);
        GetYarnString(sc, line & 1 ? yarn_2used : yarn_1used, TRUE);
        hWndTmp = GetDlgItem(hWnd, ID_LEFT_YARN);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        GetYarnString(sc, line & 1 ? yarn_1used : yarn_2used, TRUE);
        hWndTmp = GetDlgItem(hWnd, ID_RGHT_YARN);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //dumu
        ushort dumu = 0;
        if(line & 1)
        {
            if(p->dumu2)
            {
                dumu = GetRunDumu(g_knit_data, TRUE, p->dumu2 - 1, 0);
            }
        }
        else
        {
            dumu = 0;
        }
        sprintf(sc, "%u", dumu);
        hWndTmp = GetDlgItem(hWnd, IDC_DUMU1_NAME);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        if(line & 1)
        {
            dumu = 0;
        }
        else
        {
            if(p->dumu1)
            {
                dumu = GetRunDumu(g_knit_data, TRUE, p->dumu1 - 1, 1);
            }
        }
        sprintf(sc, "%u", dumu);
        hWndTmp = GetDlgItem(hWnd, IDC_DUMU2_NAME);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        if(line & 1)
        {
            if(p->dumu2)
            {
                dumu = GetRunDumu(g_knit_data, FALSE, p->dumu2 - 1, 0);
            }
        }
        else
        {
            dumu = 0;
        }
        sprintf(sc, "%u", dumu);
        hWndTmp = GetDlgItem(hWnd, IDC_DUMU5_NAME);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        if(line & 1)
        {
            dumu = 0;
        }
        else
        {
            if(p->dumu1)
            {
                dumu = GetRunDumu(g_knit_data, FALSE, p->dumu1 - 1, 1);
            }
        }
        sprintf(sc, "%u", dumu);
        hWndTmp = GetDlgItem(hWnd, IDC_DUMU6_NAME);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        if(line & 1)
        {
            if(p->dumu1)
            {
                dumu = GetRunDumu(g_knit_data, TRUE, p->dumu1 - 1, 2);
            }
        }
        else
        {
            dumu = 0;
        }
        sprintf(sc, "%u", dumu);
        hWndTmp = GetDlgItem(hWnd, IDC_DUMU3_NAME);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        if(line & 1)
        {
            dumu = 0;
        }
        else
        {
            if(p->dumu2)
            {
                dumu = GetRunDumu(g_knit_data, TRUE, p->dumu2 - 1, 3);
            }
        }
        sprintf(sc, "%u", dumu);
        hWndTmp = GetDlgItem(hWnd, IDC_DUMU4_NAME);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        if(line & 1)
        {
            if(p->dumu1)
            {
                dumu = GetRunDumu(g_knit_data, FALSE, p->dumu1 - 1, 2);
            }
        }
        else
        {
            dumu = 0;
        }
        sprintf(sc, "%u", dumu);
        hWndTmp = GetDlgItem(hWnd, IDC_DUMU7_NAME);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        if(line & 1)
        {
            dumu = 0;
        }
        else
        {
            if(p->dumu2)
            {
                dumu = GetRunDumu(g_knit_data, FALSE, p->dumu2 - 1, 3);
            }
        }
        sprintf(sc, "%u", dumu);
        hWndTmp = GetDlgItem(hWnd, IDC_DUMU8_NAME);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        sprintf(sc, "%u", p->dumu1);
        hWndTmp = GetDlgItem(hWnd, ID_DUMU1);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        sprintf(sc, "%u", p->dumu2);
        hWndTmp = GetDlgItem(hWnd, ID_DUMU2);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //rab
        sprintf(sc, "%u", p->high_roll);
        hWndTmp = GetDlgItem(hWnd, ID_MAST_ROLL);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        sprintf(sc, "%u", GetRabRunSpeed(g_knit_data, p->high_roll - 1));
        hWndTmp = GetDlgItem(hWnd, ID_RAB_VALUE);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //rude
        hWndTmp = GetDlgItem(hWnd, IDC_RUDE);
        sprintf(sc, "%d", GetRudeDumu(g_knit_data, p->high_roll - 1));
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //roll
        sprintf(sc, "%u", p->low_roll);
        hWndTmp = GetDlgItem(hWnd, ID_AUX_ROLL);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        sprintf(sc, "%u", GetRollRunSpeed(g_knit_data, p->low_roll - 1));
        hWndTmp = GetDlgItem(hWnd, ID_ROLL_VALUE);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //speed
        sprintf(sc, "%u", p->speed);
        hWndTmp = GetDlgItem(hWnd, IDC_SPEED);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        sprintf(sc, "%u", GetMacRunSpeed(g_knit_data, p->speed - 1));
        hWndTmp = GetDlgItem(hWnd, IDC_EDIT_SPEED);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //rock
        GetRockString(sc, p->rock.drt, p->rock.needle, p->rock.flag);
        if(p->rock2_num.needle || p->rock2_dir.drt || p->rock2_dir.flag)
        {
            GetRockString(&sc[strlen(sc)], p->rock2_dir.drt,
                    p->rock2_num.needle, p->rock2_dir.flag);
        }
        if(IS_TRANSFER(p->act_1BA) || IS_TRANSFER(p->act_1FA)
                || IS_TRANSFER(p->act_2BA) || IS_TRANSFER(p->act_2FA))
        {
            strcat(sc, "t");
        }
        hWndTmp = GetDlgItem(hWnd, IDC_ROCK);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //rock speed
        sprintf(sc, "%u", GetRockSpeed(g_knit_data));
        hWndTmp = GetDlgItem(hWnd, IDC_ROCK_SPEED);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //yarn stop
        sprintf(sc, "%u", p->stop);
        hWndTmp = GetDlgItem(hWnd, IDC_YARN_STOP);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //ret len
        sprintf(sc, "%u", GetMacRetLen(g_knit_data));
        hWndTmp = GetDlgItem(hWnd, IDC_RET_LEN);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //sink
        sprintf(sc, "%u", p->sink);
        hWndTmp = GetDlgItem(hWnd, IDC_SINK);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //dmbz
        sprintf(sc, "%u", p->dmbz);
        hWndTmp = GetDlgItem(hWnd, IDC_DMBZ);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        //cycle
        FlushRunWndCycle(hWnd, line);
    }
}
/*
 *
 */
void FlushRunWndFile(HWND hWnd)
{
    HWND hTmp = GetDlgItem(hWnd, IDC_FILE_NAME);
    if(hTmp > 0)
    {
        char name[MH_FILE_NAME_MAX_LEN] = {0};
        const char *sc = GetKnitFileName(g_knit_data);
        UTF_8ToGB2312(name, sc, strlen(sc) + 1);
        SetWindowCaption(hTmp, name);
        InvalidateRect(hTmp, NULL, TRUE);
    }
    hTmp = GetDlgItem(hWnd, IDC_LINE_FINISHED);
    ushort line = GetCurrentKnitLine(g_knit_data);
    if(hTmp > 0)
    {
        char sc[128] = {0};
        sprintf(sc, "%d/%d", line, GetTotalKnitPage(g_knit_data));
        SetWindowCaption(hTmp, sc);
        InvalidateRect(hTmp, NULL, TRUE);
    }
}
/*
 * start point
 */
void FlushRunWndStartPoint(HWND hWnd)
{
    char sc[64] = {0};
    sprintf(sc, "%u", GetStartNeedle(g_knit_data));
    HWND hWndTmp = GetDlgItem(hWnd, IDC_START_POINT);
    SetWindowCaption(hWndTmp, sc);
    InvalidateRect(hWndTmp, NULL, TRUE);
}
/*
 *
 */
void FlushRunWndFinished(HWND hWnd)
{
    char sc[64] = {0};
    HWND hTmp = GetDlgItem(hWnd, IDC_KNIT_FINISHED);
    uint n = GetDoneCloth(g_knit_data);
    if(n != atoi(GetWindowCaption(hTmp)))
    {
        sprintf(sc, "%u", n);
        SetWindowCaption(hTmp, sc);
        InvalidateRect(hTmp, NULL, TRUE);
    }
}
/*
 *
 */
uchar GetRunFileSortType()
{
    uchar ret = 0;
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(g_hwnd_run);
    if(data.pwnd_run)
    {
        ret = data.pwnd_run->sort_file_type;
    }
    return ret;
}
/*
 *
 */
void SetRunFileSortType(uchar type)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(g_hwnd_run);
    if(data.pwnd_run)
    {
        data.pwnd_run->sort_file_type = type;
    }
}
/*
 *创建按钮静态文本等
 *舞者无罪
 *2014.11.25
 */
static void CreateRunInterface(HWND hWnd)
{
    //company
    CreateWindow(MH_STATIC_NAME,
        "",
        WS_CHILD | WS_VISIBLE,
        ID_ESC,
        408,
        526,
        CX_COMPANY_BMP,
        CY_COMPANY_BMP,
        hWnd, (int)&g_bmp[BMP_COMPANY]);
    char sc[MH_FILE_NAME_MAX_LEN] = {0};
    ushort current_line = GetCurrentKnitLine(g_knit_data);
    if(IsAuxConKnit(g_knit_data))
    {
        current_line = GetAuxConCurtLine(g_knit_data);
    }
    CreateWindow(MH_LABEL_NAME,
		MW_LINE_FINISHED_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		FILE_CAPTION_LEFT,
        FILE_CAPTION_TOP,
        FILE_CAPTION_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    sprintf(sc, "%d/%d", current_line, GetTotalKnitPage(g_knit_data));
	CreateWindow(MH_EDIT_NAME,
		sc,
		WS_CHILD | WS_VISIBLE,
		IDC_LINE_FINISHED,
		FILE_CAPTION_LEFT + FILE_CAPTION_WIDTH + 8,
        FILE_CAPTION_TOP,
        LINE_NAME_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_EDIT_BKGND_GREY);
	CreateWindow(MH_LABEL_NAME,
		MW_FILE_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		FILE_CAPTION_LEFT,
        FILE_CAPTION_TOP + FILE_CAPTION_HEIGHT + FILE_CAPTION_INTER,
        FILE_CAPTION_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
	const char *name = GetKnitFileName(g_knit_data);
	UTF_8ToGB2312(sc, name, strlen(name) + 1);
	CreateWindow(MH_EDIT_NAME,
		sc,
		WS_CHILD | WS_VISIBLE,
		IDC_FILE_NAME,
		FILE_CAPTION_LEFT + FILE_CAPTION_WIDTH + 8,
        FILE_CAPTION_TOP + FILE_CAPTION_HEIGHT + FILE_CAPTION_INTER,
        FILE_NAME_WIDTH * 2,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_EDIT_BKGND_GREY);
    CreateWindow(MH_LABEL_NAME,
		MW_EFFICIENCY_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		FILE_CAPTION_LEFT,
        FILE_CAPTION_TOP + (FILE_CAPTION_HEIGHT + FILE_CAPTION_INTER) * 2,
        FILE_CAPTION_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    uint t = GetKnitTime(g_knit_data);
    uint hour = t / 3600;
    uint minite = (t - hour * 3600) / 60;
    uint second = t % 60;
    sprintf(sc, "%02u:%02u:%02u", hour, minite, second);

	CreateWindow(MH_EDIT_NAME,
		sc,
		WS_CHILD | WS_VISIBLE,
		IDC_EFFICIENCY,
		FILE_CAPTION_LEFT + FILE_CAPTION_WIDTH + 8,
        FILE_CAPTION_TOP + (FILE_CAPTION_HEIGHT + FILE_CAPTION_INTER) * 2,
        FILE_NAME_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_EDIT_BKGND_GREY);


    CreateWindow(MH_LABEL_NAME,
		MW_MAC_POS_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		CX_SCREEN / 3 + FILE_CAPTION_LEFT,
        FILE_CAPTION_TOP,
        FILE_CAPTION_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);

    short needle = 0;
    GetCurrentNeedle(g_knit_data, &needle);
    sprintf(sc, "%d", needle);
	CreateWindow(MH_EDIT_NAME,
		sc,
		WS_CHILD | WS_VISIBLE,
		IDC_MAC_POS,
		CX_SCREEN / 3 + FILE_CAPTION_LEFT + FILE_CAPTION_WIDTH + 8,
        FILE_CAPTION_TOP,
        FILE_NAME_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_EDIT_BKGND_GREY);
	CreateWindow(MH_LABEL_NAME,
		MW_KNIT_FINISHED_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		CX_SCREEN / 3 + FILE_CAPTION_LEFT,
        FILE_CAPTION_TOP + (FILE_CAPTION_HEIGHT + FILE_CAPTION_INTER),
        FILE_CAPTION_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
	sprintf(sc, "%u", GetDoneCloth(g_knit_data));
	CreateWindow(MH_EDIT_NAME,
		sc,
		WS_CHILD | WS_VISIBLE,
		IDC_KNIT_FINISHED,
		CX_SCREEN / 3 + FILE_CAPTION_LEFT + FILE_CAPTION_WIDTH + 8,
        FILE_CAPTION_TOP + (FILE_CAPTION_HEIGHT + FILE_CAPTION_INTER),
        FILE_NAME_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_EDIT_BKGND_GREY);
	CreateWindow(MH_LABEL_NAME,
		MW_KNIT_TIME_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		CX_SCREEN / 3 + FILE_CAPTION_LEFT,
        FILE_CAPTION_TOP + (FILE_CAPTION_HEIGHT + FILE_CAPTION_INTER) * 2,
        FILE_CAPTION_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
	t = GetWorkTime(g_knit_data);
	hour = t / 3600;
	minite = (t - hour * 3600) / 60;
	second = t % 60;
	sprintf(sc, "%02u:%02u:%02u", hour, minite, second);
	CreateWindow(MH_EDIT_NAME,
		sc,
		WS_CHILD | WS_VISIBLE,
		IDC_KNIT_TIME,
		CX_SCREEN / 3 + FILE_CAPTION_LEFT + FILE_CAPTION_WIDTH + 8,
        FILE_CAPTION_TOP + (FILE_CAPTION_HEIGHT + FILE_CAPTION_INTER) * 2,
        FILE_NAME_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_EDIT_BKGND_GREY);


	CreateWindow(MH_LABEL_NAME,
		MW_RUN_DRT_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		CX_SCREEN * 2 / 3 + FILE_CAPTION_LEFT,
        FILE_CAPTION_TOP,
        FILE_CAPTION_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
	CreateWindow(MH_EDIT_NAME,
		current_line & 1 ? ">>>>>>" : "<<<<<<",
		WS_CHILD | WS_VISIBLE,
		IDC_LEFT_DRT,
		CX_SCREEN * 2 / 3 + FILE_CAPTION_LEFT + FILE_CAPTION_WIDTH + 8,
        FILE_CAPTION_TOP,
        FILE_NAME_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_EDIT_BKGND_GREY);
    CreateWindow(MH_LABEL_NAME,
		MW_KNIT_NUM_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		CX_SCREEN * 2 / 3 + FILE_CAPTION_LEFT,
        FILE_CAPTION_TOP + (FILE_CAPTION_HEIGHT + FILE_CAPTION_INTER),
        FILE_CAPTION_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    sprintf(sc, "%u", GetTotalCloth(g_knit_data));
	CreateWindow(MH_EDIT_NAME,
		sc,
		WS_CHILD | WS_VISIBLE,
		IDC_KNIT_NUM,
		CX_SCREEN * 2 / 3 + FILE_CAPTION_LEFT + FILE_CAPTION_WIDTH + 8,
        FILE_CAPTION_TOP + (FILE_CAPTION_HEIGHT + FILE_CAPTION_INTER),
        FILE_NAME_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_EDIT_BKGND_GREY);
    CreateWindow(MH_LABEL_NAME,
		MW_DATE_TIME_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		CX_SCREEN * 2 / 3 + FILE_CAPTION_LEFT - FILE_CAPTION_WIDTH,
        FILE_CAPTION_TOP + (FILE_CAPTION_HEIGHT + FILE_CAPTION_INTER) * 2,
        FILE_CAPTION_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    time_t curt_tm = GetSysTime(g_knit_data);
    struct tm *tm_now = localtime(&curt_tm);
    sprintf(&sc[26], "%2u/%2u/%2u %2u:%2u:%2u",
        tm_now->tm_year % 100, tm_now->tm_mon + 1, tm_now->tm_mday,
        tm_now->tm_hour, tm_now->tm_min, tm_now->tm_sec);
	CreateWindow(MH_EDIT_NAME,
		sc,
		WS_CHILD | WS_VISIBLE,
		ID_TIME_SET,
		CX_SCREEN * 2 / 3 + FILE_CAPTION_LEFT -FILE_CAPTION_WIDTH + FILE_CAPTION_WIDTH + 8,
        FILE_CAPTION_TOP + (FILE_CAPTION_HEIGHT + FILE_CAPTION_INTER) * 2,
        DATE_NAME_WIDTH,
        FILE_CAPTION_HEIGHT,
		hWnd, MH_EDIT_BKGND_GREY);
    //left COMMAND
    CreateWindow(MH_LABEL_NAME,
		MW_ROW_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		FLW_CAPTION_LEFT,
        FLW_CAPTION_TOP,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_LEFT,
		IDC_EDIT_BACKL_ROW,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + 5,
        FLW_CAPTION_TOP,
        YARN_CAPTION_WIDTH - FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //
    CreateWindow(MH_LABEL_NAME,
		"H",
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		FLW_CAPTION_LEFT,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_LEFT,
		IDC_EDIT_LEFT_CODE_BH,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + 5,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT,
        YARN_CAPTION_WIDTH - FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		MW_CMD_TUCK,
		WS_CHILD | WS_VISIBLE,
		IDC_EDIT_LEFT_CMD_BH,
		FLW_CAPTION_LEFT + YARN_CAPTION_WIDTH + 6,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //
    CreateWindow(MH_LABEL_NAME,
		"A",
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		FLW_CAPTION_LEFT,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 2,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_LEFT,
		IDC_EDIT_LEFT_CODE_BA,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + 5,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 2,
        YARN_CAPTION_WIDTH - FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		MW_CMD_KNIT,
		WS_CHILD | WS_VISIBLE,
		IDC_EDIT_LEFT_CMD_BA,
		FLW_CAPTION_LEFT + YARN_CAPTION_WIDTH + 6,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 2,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //
    CreateWindow(MH_BTN_NAME,
		MW_YARN_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_RIGHT | BS_FLAT,
		IDC_YARN,
		FLW_CAPTION_LEFT,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 4,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    CreateWindow(MH_BTN_NAME,
		MW_YARN_CHANGE_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_LEFT | BS_FLAT,
		ID_LEFT_YARN,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + 5,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 4,
        YARN_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    //
    CreateWindow(MH_LABEL_NAME,
		"A",
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		FLW_CAPTION_LEFT,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 6,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_LEFT,
		IDC_EDIT_LEFT_CODE_FA,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + 5,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 6,
        YARN_CAPTION_WIDTH - FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		MW_CMD_KNIT,
		WS_CHILD | WS_VISIBLE,
		IDC_EDIT_LEFT_CMD_FA,
		FLW_CAPTION_LEFT + YARN_CAPTION_WIDTH + 6,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 6,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //
    CreateWindow(MH_LABEL_NAME,
		"H",
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		FLW_CAPTION_LEFT,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_LEFT,
		IDC_EDIT_LEFT_CODE_FH,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + 5,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7,
        YARN_CAPTION_WIDTH - FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		MW_CMD_TUCK,
		WS_CHILD | WS_VISIBLE,
		IDC_EDIT_LEFT_CMD_FH,
		FLW_CAPTION_LEFT + YARN_CAPTION_WIDTH + 6,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //
    CreateWindow(MH_LABEL_NAME,
		MW_ROW_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_STATIC,
		FLW_CAPTION_LEFT,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 8,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_LEFT,
		IDC_EDIT_FRNTL_ROW,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + 5,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 8,
        YARN_CAPTION_WIDTH - FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //left dumu
    CreateWindow(MH_LABEL_NAME,
		MW_DUMU1_CAPTION,
		WS_CHILD | WS_VISIBLE,
		IDC_STATIC,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + YARN_CAPTION_WIDTH + 20,
        FLW_CAPTION_TOP - 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		MW_DUMU2_CAPTION,
		WS_CHILD | WS_VISIBLE,
		IDC_STATIC,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH * 2 + YARN_CAPTION_WIDTH + 30,
        FLW_CAPTION_TOP - 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE,
		IDC_DUMU1_NAME,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + YARN_CAPTION_WIDTH + 20,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT + 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE,
		IDC_DUMU2_NAME,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH * 2 + YARN_CAPTION_WIDTH + 30,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT + 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE,
		IDC_DUMU5_NAME,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + YARN_CAPTION_WIDTH + 20,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7 - 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE,
		IDC_DUMU6_NAME,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH * 2 + YARN_CAPTION_WIDTH + 30,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7 - 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow(MH_LABEL_NAME,
        MW_DUMU5_CAPTION,
		WS_CHILD | WS_VISIBLE,
		IDC_STATIC,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + YARN_CAPTION_WIDTH + 20,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 8 + 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
        MW_DUMU6_CAPTION,
		WS_CHILD | WS_VISIBLE,
		IDC_STATIC,
		FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH * 2 + YARN_CAPTION_WIDTH + 30,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 8 + 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //right COMMAND
    CreateWindow(MH_LABEL_NAME,
		MW_ROW_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_LEFT,
		IDC_STATIC,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH,
        FLW_CAPTION_TOP,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_EDIT_BACKR_ROW,
		CX_SCREEN - CX_EDGE_RIGHT - YARN_CAPTION_WIDTH - 5,
        FLW_CAPTION_TOP,
        YARN_CAPTION_WIDTH - FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //
    CreateWindow(MH_LABEL_NAME,
		"H",
		WS_CHILD | WS_VISIBLE | BS_LEFT,
		IDC_STATIC,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_EDIT_RGHT_CODE_BH,
		CX_SCREEN - CX_EDGE_RIGHT - YARN_CAPTION_WIDTH - 5,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT,
        YARN_CAPTION_WIDTH - FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		MW_CMD_TUCK,
		WS_CHILD | WS_VISIBLE,
		IDC_EDIT_RGHT_CMD_BH,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH - YARN_CAPTION_WIDTH - 6,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //
    CreateWindow(MH_LABEL_NAME,
		"A",
		WS_CHILD | WS_VISIBLE | BS_LEFT,
		IDC_STATIC,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 2,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_EDIT_RGHT_CODE_BA,
		CX_SCREEN - CX_EDGE_RIGHT - YARN_CAPTION_WIDTH - 5,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 2,
        YARN_CAPTION_WIDTH - FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		MW_CMD_KNIT,
		WS_CHILD | WS_VISIBLE,
		IDC_EDIT_RGHT_CMD_BA,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH - YARN_CAPTION_WIDTH - 6,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 2,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //
    CreateWindow(MH_BTN_NAME,
		MW_YARN_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_LEFT | BS_FLAT,
		IDC_YARN,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 4,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    CreateWindow(MH_BTN_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_RIGHT | BS_FLAT,
		ID_RGHT_YARN,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH - YARN_CAPTION_WIDTH - 5,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 4,
        YARN_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    //
    CreateWindow(MH_LABEL_NAME,
		"A",
		WS_CHILD | WS_VISIBLE | BS_LEFT,
		IDC_STATIC,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 6,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_EDIT_RGHT_CODE_FA,
		CX_SCREEN - CX_EDGE_RIGHT - YARN_CAPTION_WIDTH - 5,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 6,
        YARN_CAPTION_WIDTH - FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		MW_CMD_KNIT,
		WS_CHILD | WS_VISIBLE,
		IDC_EDIT_RGHT_CMD_FA,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH - YARN_CAPTION_WIDTH - 6,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 6,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //
    CreateWindow(MH_LABEL_NAME,
		"H",
		WS_CHILD | WS_VISIBLE | BS_LEFT,
		IDC_STATIC,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_EDIT_RGHT_CODE_FH,
		CX_SCREEN - CX_EDGE_RIGHT - YARN_CAPTION_WIDTH - 5,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7,
        YARN_CAPTION_WIDTH - FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		MW_CMD_TUCK,
		WS_CHILD | WS_VISIBLE,
		IDC_EDIT_RGHT_CMD_FH,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH - YARN_CAPTION_WIDTH - 6,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //
    CreateWindow(MH_LABEL_NAME,
		MW_ROW_CAPTION,
		WS_CHILD | WS_VISIBLE | BS_LEFT,
		IDC_STATIC,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 8,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE | BS_RIGHT,
		IDC_EDIT_FRNTR_ROW,
		CX_SCREEN - CX_EDGE_RIGHT - YARN_CAPTION_WIDTH - 5,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 8,
        YARN_CAPTION_WIDTH - FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //dumu
    CreateWindow(MH_LABEL_NAME,
		MW_DUMU3_CAPTION,
		WS_CHILD | WS_VISIBLE,
		IDC_STATIC,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 3 - YARN_CAPTION_WIDTH - 30,
        FLW_CAPTION_TOP - 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		MW_DUMU4_CAPTION,
		WS_CHILD | WS_VISIBLE,
		IDC_STATIC,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 2 - YARN_CAPTION_WIDTH - 20,
        FLW_CAPTION_TOP - 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE,
		IDC_DUMU3_NAME,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 3 - YARN_CAPTION_WIDTH - 30,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT + 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE,
		IDC_DUMU4_NAME,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 2 - YARN_CAPTION_WIDTH - 20,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT + 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE,
		IDC_DUMU7_NAME,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 3 - YARN_CAPTION_WIDTH - 30,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7 - 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow(MH_LABEL_NAME,
		"0",
		WS_CHILD | WS_VISIBLE,
		IDC_DUMU8_NAME,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 2 - YARN_CAPTION_WIDTH - 20,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7 - 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_COLOR_1GROUP);
    CreateWindow(MH_LABEL_NAME,
        MW_DUMU7_CAPTION,
		WS_CHILD | WS_VISIBLE,
		IDC_STATIC,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 3 - YARN_CAPTION_WIDTH - 30,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 8 + 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    CreateWindow(MH_LABEL_NAME,
        MW_DUMU8_CAPTION,
		WS_CHILD | WS_VISIBLE,
		IDC_STATIC,
		CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 2 - YARN_CAPTION_WIDTH - 20,
        FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 8 + 1,
        FLW_CAPTION_WIDTH,
        FLW_CAPTION_HEIGHT,
		hWnd, MH_LABEL_BKGND_BLACK | MH_LABEL_TEXT_WHITE);
    //reset...
    MH_CTRL_STATE *ctrlReset = NEW_MH_CTRL_STATE();
    if(ctrlReset)
    {
        LoadBitmap(HDC_SCREEN, &ctrlReset->bmp[MH_CTRL_STATE_NORM], GET_RESET_NORM_BMP());
        LoadBitmap(HDC_SCREEN, &ctrlReset->bmp[MH_CTRL_STATE_DOWN], GET_RESET_DOWN_BMP());
    }
	CreateWindow(MH_CTRL_STATE_NAME,
		"",
		WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
		ID_BTN_RESET,
		RESET_CTRL_LEFT, RESET_CTRL_TOP, RESET_CTRL_WIDTH, RESET_CTRL_HEIGHT,
		hWnd, (int)ctrlReset);
    //hd
    MH_CTRL_STATE *ctrlHD = NEW_MH_CTRL_STATE();
    if(ctrlHD)
    {
        LoadBitmap(HDC_SCREEN, &ctrlHD->bmp[MH_CTRL_STATE_NORM], GET_HD_NORM_BMP());
        LoadBitmap(HDC_SCREEN, &ctrlHD->bmp[MH_CTRL_STATE_DOWN], GET_HD_DOWN_BMP());
    }
    uchar hd = GetHangDingEnable(g_knit_data);
    ctrlHD->state = (hd == HD_START) ? TRUE : FALSE;
	CreateWindow(MH_CTRL_STATE_NAME,
		"",
		WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
		ID_BTN_HD,
		RESET_CTRL_LEFT + (RESET_CTRL_WIDTH + RESET_CTRL_INTER),
        RESET_CTRL_TOP, RESET_CTRL_WIDTH, RESET_CTRL_HEIGHT,
		hWnd, (int)ctrlHD);
    //low speed
    MH_CTRL_STATE *ctrlSpeed = NEW_MH_CTRL_STATE();
    if(ctrlSpeed)
    {
        LoadBitmap(HDC_SCREEN, &ctrlSpeed->bmp[MH_CTRL_STATE_NORM], GET_SPEED_NORM_BMP());
        LoadBitmap(HDC_SCREEN, &ctrlSpeed->bmp[MH_CTRL_STATE_DOWN], GET_SPEED_DOWN_BMP());
    }
    ctrlSpeed->state = GetGuiSpeedType(g_knit_data) == SPEED_HIGH ? TRUE : FALSE;
    CreateWindow (MH_CTRL_STATE_NAME,
        "",
        WS_CHILD | WS_VISIBLE | WS_VISIBLE,
        ID_BTN_SPEED,
        RESET_CTRL_LEFT + (RESET_CTRL_WIDTH + RESET_CTRL_INTER) * 2,
        RESET_CTRL_TOP, RESET_CTRL_WIDTH, RESET_CTRL_HEIGHT,
        hWnd, (int)ctrlSpeed);
    //Piece lock
    MH_CTRL_STATE *ctrlLock = NEW_MH_CTRL_STATE();
    if(ctrlLock)
    {
        LoadBitmap(HDC_SCREEN, &ctrlLock->bmp[MH_CTRL_STATE_NORM], GET_PIECE_LOCK_NORM_BMP());
        LoadBitmap(HDC_SCREEN, &ctrlLock->bmp[MH_CTRL_STATE_DOWN], GET_PIECE_LOCK_DOWN_BMP());
        if(GetPieceLock(g_knit_data))
        {
            ctrlLock->state = TRUE;
        }
    }
	CreateWindow(MH_CTRL_STATE_NAME,
		"",
		WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
		ID_PIECE_LOCK,
		RESET_CTRL_LEFT + (RESET_CTRL_WIDTH + RESET_CTRL_INTER) * 3,
        RESET_CTRL_TOP, RESET_CTRL_WIDTH, RESET_CTRL_HEIGHT,
		hWnd, (int)ctrlLock);
    //warn enable
    MH_CTRL_STATE *ctrlWarn = NEW_MH_CTRL_STATE();
    if(ctrlWarn)
    {
        LoadBitmap(HDC_SCREEN, &ctrlWarn->bmp[MH_CTRL_STATE_NORM], GET_WARN_ENABLE_NORM_BMP());
        LoadBitmap(HDC_SCREEN, &ctrlWarn->bmp[MH_CTRL_STATE_DOWN], GET_WARN_ENABLE_DOWN_BMP());
    }
	CreateWindow(MH_CTRL_STATE_NAME,
		"",
		WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
		ID_WARN_ENABLE,
		RESET_CTRL_LEFT + (RESET_CTRL_WIDTH + RESET_CTRL_INTER) * 4,
        RESET_CTRL_TOP, RESET_CTRL_WIDTH, RESET_CTRL_HEIGHT,
		hWnd, (int)ctrlWarn);
    //yarn up
    MH_CTRL_STATE *ctrlYarn = NEW_MH_CTRL_STATE();
    if(ctrlYarn)
    {
        LoadBitmap(HDC_SCREEN, &ctrlYarn->bmp[MH_CTRL_STATE_NORM], GET_YARN_UP_NORM_BMP());
        LoadBitmap(HDC_SCREEN, &ctrlYarn->bmp[MH_CTRL_STATE_DOWN], GET_YARN_UP_DOWN_BMP());
    }
	CreateWindow(MH_CTRL_STATE_NAME,
	    MW_YARN_UP_CAPTION,
	    WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
	    ID_YARN_UP,
	    RESET_CTRL_LEFT + (RESET_CTRL_WIDTH + RESET_CTRL_INTER) * 5,
        RESET_CTRL_TOP, RESET_CTRL_WIDTH, RESET_CTRL_HEIGHT,
	    hWnd, (int)ctrlYarn);
    //help
    MH_CTRL_STATE *ctrlHelp = NEW_MH_CTRL_STATE();
    if(ctrlHelp)
    {
        LoadBitmap(HDC_SCREEN, &ctrlHelp->bmp[MH_CTRL_STATE_NORM], GET_HELP_NORM_BMP());
        LoadBitmap(HDC_SCREEN, &ctrlHelp->bmp[MH_CTRL_STATE_DOWN], GET_HELP_DOWN_BMP());
    }
    CreateWindow(MH_CTRL_STATE_NAME,
        "",
        WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
        ID_HELP,
        RESET_CTRL_LEFT + (RESET_CTRL_WIDTH + RESET_CTRL_INTER) * 6,
        RESET_CTRL_TOP, RESET_CTRL_WIDTH, RESET_CTRL_HEIGHT,
        hWnd, (int)ctrlHelp);
    //dumu1
    CreateWindow(MH_BTN_NAME,
        MW_RUN_DUMU1_CAPTION,
        WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
        ID_DUMU,
        DUMU1_CAPTION_LEFT,
        DUMU1_CAPTION_TOP,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    CreateWindow(MH_BTN_NAME,
	    "1",
	    WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
	    ID_DUMU1,
	    DUMU1_CAPTION_LEFT + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP,
        SECT_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
	    hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //dumu2
    CreateWindow(MH_BTN_NAME,
		MW_RUN_DUMU2_CAPTION,
		WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
		ID_DUMU,
		DUMU1_CAPTION_LEFT,
        DUMU1_CAPTION_TOP + DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow(MH_BTN_NAME,
		"1",
		WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
		ID_DUMU2,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER,
        SECT_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //rab
	CreateWindow(MH_BTN_NAME,
		MW_MAST_ROLL_CAPTION,
		WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
		ID_RAB,
		DUMU1_CAPTION_LEFT,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 2,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow(MH_BTN_NAME,
		"1",
		WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
		ID_MAST_ROLL,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 2,
        SECT_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    CreateWindow(MH_BTN_NAME,
		"-",
		WS_CHILD | BS_FLAT | WS_VISIBLE,
		ID_RAB,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_WIDTH + SECT_RECT_WIDTH,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 2,
        10,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow(MH_BTN_NAME,
	    "30",
	    WS_CHILD | BS_FLAT | BS_LEFT | WS_VISIBLE,
	    ID_RAB_VALUE,
	    DUMU1_CAPTION_LEFT + DUMU1_CAPTION_WIDTH + SECT_RECT_WIDTH + 10,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 2,
        DUMU1_NAME_WIDTH,
        DUMU1_CAPTION_HEIGHT,
	    hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //roll
    CreateWindow(MH_BTN_NAME,
        MW_AUX_ROLL_CAPTION,
        WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
        ID_ROLL,
        DUMU1_CAPTION_LEFT,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 3,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    CreateWindow(MH_BTN_NAME,
        "1",
        WS_CHILD | BS_FLAT | BS_LEFT | WS_VISIBLE,
        ID_AUX_ROLL,
        DUMU1_CAPTION_LEFT + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 3,
        SECT_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    CreateWindow(MH_BTN_NAME,
		"-",
		WS_CHILD | BS_FLAT | WS_VISIBLE,
		ID_ROLL,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_WIDTH + SECT_RECT_WIDTH,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 3,
        10,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow (MH_BTN_NAME,
		"30",
		WS_CHILD | BS_FLAT | BS_LEFT | WS_VISIBLE,
		ID_ROLL_VALUE,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_WIDTH + SECT_RECT_WIDTH + 10,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 3,
        DUMU1_NAME_WIDTH,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //speed
    CreateWindow(MH_BTN_NAME,
        MW_SPEED_CAPTION,
        WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
        ID_SPEED,
        DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER,
        DUMU1_CAPTION_TOP,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    CreateWindow(MH_BTN_NAME,
	    "1",
	    WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
	    IDC_SPEED,
	    DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP,
        SECT_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
	    hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    CreateWindow(MH_BTN_NAME,
		"-",
		WS_CHILD | BS_FLAT | WS_VISIBLE,
		ID_SPEED,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER + DUMU1_CAPTION_WIDTH + SECT_RECT_WIDTH,
        DUMU1_CAPTION_TOP,
        10,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow(MH_BTN_NAME,
	    "30",
	    WS_CHILD | BS_FLAT | BS_LEFT | WS_VISIBLE,
	    IDC_EDIT_SPEED,
	    DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER + DUMU1_CAPTION_WIDTH + SECT_RECT_WIDTH + 10,
        DUMU1_CAPTION_TOP,
        DUMU1_NAME_WIDTH,
        DUMU1_CAPTION_HEIGHT,
	    hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //rock
    CreateWindow(MH_BTN_NAME,
		MW_ROCK_CAPTION,
		WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
		ID_ROCK,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER,
        DUMU1_CAPTION_TOP + DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow(MH_BTN_NAME,
		"1",
		WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
		IDC_ROCK,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER,
        50,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //rock speed
	CreateWindow(MH_BTN_NAME,
		MW_SPEED_ROCK_CAPTION,
		WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
		ID_ROCK_SPEED,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 2,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow(MH_BTN_NAME,
		"1",
		WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
		IDC_ROCK_SPEED,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 2,
        SECT_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //yarn stop
    CreateWindow(MH_BTN_NAME,
        MW_YARN_STOP_CAPTION,
        WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
        ID_YARN_STOP,
        DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 3,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    CreateWindow(MH_BTN_NAME,
        "1",
        WS_CHILD | BS_FLAT | BS_LEFT | WS_VISIBLE,
        IDC_YARN_STOP,
        DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 3,
        SECT_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //ret len
    CreateWindow(MH_BTN_NAME,
        MW_RET_INTER_CAPTION,
        WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
        ID_RET_LEN,
        DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2,
        DUMU1_CAPTION_TOP,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    CreateWindow(MH_BTN_NAME,
	    "1",
	    WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
	    IDC_RET_LEN,
	    DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP,
        SECT_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
	    hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //sink
    CreateWindow(MH_BTN_NAME,
		MW_SINK_CAPTION,
		WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
		ID_SINK,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2,
        DUMU1_CAPTION_TOP + DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow(MH_BTN_NAME,
		"1",
		WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
		IDC_SINK,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER,
        SECT_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //dumu before
	CreateWindow(MH_BTN_NAME,
		MW_DUMU_BEFORE_CAPTION,
		WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
		ID_DUMU_BEFORE,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 2,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow(MH_BTN_NAME,
		"1",
		WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
		IDC_DUMU_BEFORE,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 2,
        SECT_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //intasia
    CreateWindow(MH_BTN_NAME,
        MW_INTASIA_CAPTION,
        WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
        ID_INTASIA,
        DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 3,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    CreateWindow(MH_BTN_NAME,
        "1",
        WS_CHILD | BS_FLAT | BS_LEFT | WS_VISIBLE,
        IDC_INTASIA,
        DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 3,
        SECT_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //start point
    CreateWindow(MH_BTN_NAME,
        MW_START_POINT_CAPTION,
        WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
        ID_START_POINT,
        DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER,
        DUMU1_CAPTION_TOP,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    sprintf(sc, "%u", GetStartNeedle(g_knit_data));
    CreateWindow(MH_BTN_NAME,
	    sc,
	    WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
	    IDC_START_POINT,
	    DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP,
        CYCLE_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
	    hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //dmbz
    CreateWindow(MH_BTN_NAME,
		MW_DMBZ_CAPTION,
		WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
		ID_DMBZ,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER,
        DUMU1_CAPTION_TOP + DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow(MH_BTN_NAME,
		"1",
		WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
		IDC_DMBZ,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER,
        CYCLE_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
	CreateWindow(MH_BTN_NAME,
	    GetString(701),
	    WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
	    ID_RUDE,
	    DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER,
	    DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 2,
	    DUMU1_CAPTION_WIDTH,
	    DUMU1_CAPTION_HEIGHT,
	    hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow(MH_BTN_NAME,
	    "0",
	    WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
	    IDC_RUDE,
	    DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER + DUMU1_CAPTION_WIDTH + 2,
	    DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 2,
	    CYCLE_RECT_WIDTH - 2,
	    DUMU1_CAPTION_HEIGHT,
	    hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //cycle start
    CreateWindow(MH_BTN_NAME,
        MW_CYCLE_START_CAPTION,
        WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
        ID_CYCLE_START,
        DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER * 2,
        DUMU1_CAPTION_TOP,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    CreateWindow(MH_BTN_NAME,
	    "",
	    WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
	    IDC_CYCLE_START,
	    DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER * 2 + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP,
        CYCLE_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
	    hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //cycle end
    CreateWindow(MH_BTN_NAME,
		MW_CYCLE_END_CAPTION,
		WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
		ID_CYCLE_END,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER * 2,
        DUMU1_CAPTION_TOP + DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow(MH_BTN_NAME,
		"",
		WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
		IDC_CYCLE_END,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER * 2 + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER,
        CYCLE_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //cycle num
	CreateWindow(MH_BTN_NAME,
		MW_CYCLE_NUM_CAPTION,
		WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
		ID_CYCLE_NUM,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER * 2,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 2,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
	CreateWindow(MH_BTN_NAME,
		"",
		WS_CHILD | BS_LEFT | BS_FLAT | WS_VISIBLE,
		IDC_CYCLE_NUM,
		DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER * 2 + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 2,
        CYCLE_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
		hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    //cycle left
    CreateWindow(MH_BTN_NAME,
        MW_CYCLE_LEFT_CAPTION,
        WS_CHILD | BS_RIGHT | BS_FLAT | WS_VISIBLE,
        ID_CYCLE_LEFT,
        DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER * 2,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 3,
        DUMU1_CAPTION_WIDTH,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE);
    CreateWindow(MH_BTN_NAME,
        "",
        WS_CHILD | BS_FLAT | BS_LEFT | WS_VISIBLE,
        IDC_CYCLE_LEFT,
        DUMU1_CAPTION_LEFT + DUMU1_CAPTION_INTER * 2 + SINK_CAPTION_INTER * 2 + DUMU1_CAPTION_WIDTH + 2,
        DUMU1_CAPTION_TOP + (DUMU1_CAPTION_HEIGHT + SECT_RECT_INTER) * 3,
        CYCLE_RECT_WIDTH - 2,
        DUMU1_CAPTION_HEIGHT,
        hWnd, MH_BTN_BKGND_BLACK | MH_BTN_TEXT_WHITE | MH_BTN_GRAY_BORDER);
    ReadConPage(hWnd, current_line);
}
/*
 * reset machine
 * param start_line: start line of running(1-start)
 */
static void OnReset(HWND hWnd, int start_line, int type)
{
    ForbidFeedback(g_knit_data, TRUE);
    int ret = ResetMachine(g_knit_data, start_line, type);
    ForbidFeedback(g_knit_data, FALSE);

    HWND hTmp = GetDlgItem(hWnd, ID_BTN_HD);
    if(type == RESET_HD)
    {
        SetCtrlState(hTmp, TRUE);
    }
    else
    {
        SetCtrlState(hTmp, FALSE);
    }
    InvalidateRect(hTmp, NULL, TRUE);

   ReadConPage(hWnd, start_line);

    WND_RUN *p = (WND_RUN*)GetWindowAdditionalData(hWnd);
    if(!GetNetworkState(g_knit_data))
    {
        if(ret)
        {
            p->wnd_error = ret;
            UpdateRunWarn(hWnd, ret);
        }
        else
        {
            p->error_code = RUN_FB_RESET_WAIT;
            UpdateRunWarn(hWnd, p->error_code);
        }//*/
    }
    printf("reset machine: %d\n", ret);
}
/*
 * hang ding
 */
static void OnHangDing()
{
    HangDing(g_knit_data);
}
/*
 * switch yarn
 */
static void OnSwitchYarn()
{
    SwitchYarn(g_knit_data);
}
/*
 * piece/cloth lock
 */
static void OnLockCloth()
{
    LockCloth(g_knit_data);
}
/*
 * switch speed
 */
static void OnSwitchSpeed()
{
    SwitchSpeed(g_knit_data);
}
/*
 * switch speed
 */
static void OnSwitchSpeedHigh()
{
    SetSpeedState(g_knit_data, SPEED_HIGH);
}
/*
 * update warn
 */
void UpdateRunWarn(HWND hWnd, int errcode)
{
    char sc[1024] = {0};
    switch(errcode)
    {
    case ERROR_NO_KNIT_FILE:
        strcat(sc, MW_NO_RUN_FILE_ERROR);
        break;
    case ERROR_FLOWER_WIDTH:
        strcat(sc, MW_FLOWER_WIDTH_ERROR);
        break;
    case ERROR_FLOWER_HEIGHT:
        strcat(sc, MW_FLOWER_HEIGHT_ERROR);
        break;
    case ERROR_CONTROL_HEIGHT:
        strcat(sc, MW_CONTROL_HEIGHT_ERROR);
        break;
    case ERROR_STATE_DIFF:
        strcat(sc, MW_STATE_DIFF_ERROR);
        break;
    case ERROR_DATA_NOT_SEND:
        strcat(sc, MW_PARAM_NOT_READY);
        break;
    case ERROR_BOARD_AGAINST_EXTENT_PIECE:
        strcat(sc, MW_BOARD_AGAINST_EXTENT);
        break;
    case ERROR_STATE_RESET:
        strcat(sc, MW_RESET_ERROR);
        break;
    case ERROR_STATE_RUN:
        strcat(sc, MW_STATE_RUN_ERROR);
        break;
    case ERROR_LOCK_ROW:
        break;
    case ERROR_UNLOCK_ROW:
        break;
    case ERROR_TASK_FINISHED:
        strcat(sc, MW_TASK_FINISH_CAPTION);
        break;
    case RUN_FB_ERROR_YARN_DOWN:
        strcat(sc, GetString(472));
        break;
    case RUN_ERROR_NET:
        strcat(sc, MW_NET_ERROR);
        break;
    case RUN_FB_RESET_WAIT:
        strcat(sc, MW_WAIT_RESET);
        break;
    case RUN_FB_NONE:
        break;
    case RUN_FB_UPS_WARN:
        strcat(sc, MW_UDP_WARN);
        break;
    case RUN_FB_SIFU_WARN:
        strcat(sc, MW_MOTOR_WARN);
        break;
    case RUN_FB_ROCKSIFU_WARN:
        strcat(sc, MW_ROCK_WARN);
        break;
    case RUN_FB_LEFTSHA_WARN:
        strcat(sc, MW_LEFT_BREAK_WARN);
        break;
    case RUN_FB_RIGHTSHA_WARN:
        strcat(sc, MW_RIGHT_BREAK_WARN);
        break;
    case RUN_FB_LEFTSOSHA_WARN:
        strcat(sc, MW_LEFT_FEED_BREAK_WARN);
        break;
    case RUN_FB_RIGHTSOSHA_WARN:
        strcat(sc, MW_RIGHT_FEED_BREAK_WARN);
        break;
    case RUN_FB_PRESAFEDOOR_WARN:
        strcat(sc, MW_FRONT_SAFE_DOOR_WARN);
        break;
    case RUN_FB_LFBCDOOR_WARN:
        strcat(sc, MW_LB_SAFE_DOOR_WARN);
        break;
    case RUN_FB_RGBCDOOR_WARN:
        strcat(sc, MW_RB_SAFE_DOOR_WARN);
        break;
    case RUN_FB_HIGHROLLER_WARN:
        strcat(sc, MW_RAB_WARN);
        break;
    case RUN_FB_HIGHROLLER_CLOSE_WARN:
        strcat(sc, GetString(408));
        break;
    case RUN_FB_QUICKSTOP_WARN:
        strcat(sc, MW_SCRAM_WARN);
        break;
    case RUN_FB_CHUSHAQI_WARN:
        strcat(sc, MW_STORE_WARN);
        break;
    case RUN_FB_QIDISAFEDOOR_WARN:
        strcat(sc, MW_BOARD_SAFE_DOOR_WARN);
        break;
    case RUN_FB_DROP_BAD_WARN:
        strcat(sc, MW_DROP_BAD_WARN);
        break;
    case RUN_FB_LEFT_RUBBER:
        strcat(sc, MW_LEFT_RUBBER_WARN);
        break;
    case RUN_FB_RIGHT_RUBBER:
        strcat(sc, MW_RIGHT_RUBBER_WARN);
        break;
    case RUN_FB_PO_SYS12V:
        strcat(sc, MW_12V_WARN);
        break;
    case RUN_FB_PO_SYS24V:
        strcat(sc, MW_24V_WARN);
        break;
    case RUN_FB_TIANXIAN_WARN:
        strcat(sc, MW_BAlCONY_WARN);
        break;
    case RUN_FB_PAYMENT_WARN:
        strcat(sc, GetString(673));
        break;
    case RUN_FB_PRESHAKE_WARN:
        strcat(sc, MW_FRONT_SHAKE_WARN);
        break;
    case RUN_FB_BACKSHAKE_WARN:
        strcat(sc, MW_BACK_SHAKE_WARN);
        break;
    case RUN_FB_ERROR_RESET_ROCK:
        strcat(sc, MW_RESET_ROCK_ERROR);
        break;
    case RUN_FB_NETMESSAGE_WARN:
        strcat(sc, MW_NET_WARN);
        break;
    case RUN_FB_ERROR_CARRIGE:
        strcat(sc, MW_CARRIGE_WARN);
        break;
    case RUN_FB_ERROR_COMB:
        strcat(sc, MW_BORAD_COMM_WARN);
        break;
    case RUN_FB_STOP_STATE:
        return;
    case RUN_FB_SLOW_STATE:
    case RUN_FB_QUICK_STATE:
    case RUN_FB_KNOT_STATE:
        errcode = 0;
        break;
    case RUN_FB_STOP_LINE:
        strcat(sc, MW_STOP_LINE_CAPTION);
        break;
    case RUN_FB_CLOTH_FINISH:
        {
            strcat(sc, MW_CLOTH_FINISH_CAPTION);
            HWND hTmp = GetDlgItem(hWnd, ID_PIECE_LOCK);
            SetCtrlState(hTmp, FALSE);
            InvalidateRect(hTmp, NULL, TRUE);
        }
        break;
    case RUN_FB_TASK_FINISH:
        strcat(sc, MW_TASK_FINISH_CAPTION);
        break;
    case RUN_FB_ERROR_QTZ:
        strcat(sc, MW_FRONT_PROBE_WARN);
        break;
    case RUN_FB_ERROR_HTZ:
        strcat(sc, MW_BACK_PROBE_WARN);
        break;
    case RUN_FB_ERROR_YARN:
        strcat(sc, MW_YARN_ERROR);
        break;
    case RUN_FB_ERROR_CAM:
        strcat(sc, MW_CAM_ERROR);
        break;
    case RUN_FB_ERROR_XZQ:
        strcat(sc, MW_SELECT_WARN);
        break;
    case RUN_FB_ERROR_DUMUF1:
        strcat(sc, MW_FRONT_1DUMU_ERROR);
        break;
    case RUN_FB_ERROR_DUMUF2:
        strcat(sc, MW_FRONT_2DUMU_ERROR);
        break;
    case RUN_FB_ERROR_DUMUB1:
        strcat(sc, MW_BACK_1DUMU_ERROR);
        break;
    case RUN_FB_ERROR_DUMUB2:
        strcat(sc, MW_BACK_2DUMU_ERROR);
        break;
    case RUN_FB_ERROR_SINKF:
        strcat(sc, MW_FRONT_SINK_ERROR);
        break;
    case RUN_FB_ERROR_DUMUF3:
        strcat(sc, MW_FRONT_3DUMU_ERROR);
        break;
    case RUN_FB_ERROR_DUMUF4:
        strcat(sc, MW_FRONT_4DUMU_ERROR);
        break;
    case RUN_FB_ERROR_DUMUB3:
        strcat(sc, MW_BACK_3DUMU_ERROR);
        break;
    case RUN_FB_ERROR_DUMUB4:
        strcat(sc, MW_BACK_4DUMU_ERROR);
        break;
    case RUN_FB_ERROR_SINKB:
        strcat(sc, MW_BACK_SINK_ERROR);
        break;
    case RUN_FB_YARN_24V_WARN:
        strcat(sc, MW_YARN_24V_WARN);
        break;
    case RUN_FB_XZ24V_WARN:
        strcat(sc, MW_SELECT_24V_WARN);
        break;
    case RUN_FB_XZN24V_WARN:
        strcat(sc, MW_SELECT_N24V_WARN);
        break;
    case RUN_FB_DUMU_24V_WARN:
        strcat(sc, MW_DUMU_24V_WARN);
        break;
    case RUN_FB_YARN_OVERCURRENT:
        strcat(sc, MW_YARN_OVER_WARN);
        break;
    case RUN_FB_CAM_OVERCURRENT:
        strcat(sc, MW_CAM_OVER_WARN);
        break;
    case RUN_FB_OC_XZQ1:
        strcat(sc, MW_FRONT_1XZQ_OVER_WARN);
        break;
    case RUN_FB_OC_XZQ2:
        strcat(sc, MW_FRONT_2XZQ_OVER_WARN);
        break;
    case RUN_FB_OC_XZQ3:
        strcat(sc, MW_FRONT_3XZQ_OVER_WARN);
        break;
    case RUN_FB_OC_XZQ4:
        strcat(sc, MW_FRONT_4XZQ_OVER_WARN);
        break;
    case RUN_FB_OC_XZH1:
        strcat(sc, MW_BACK_1XZQ_OVER_WARN);
        break;
    case RUN_FB_OC_XZH2:
        strcat(sc, MW_BACK_2XZQ_OVER_WARN);
        break;
    case RUN_FB_OC_XZH3:
        strcat(sc, MW_BACK_3XZQ_OVER_WARN);
        break;
    case RUN_FB_OC_XZH4:
        strcat(sc, MW_BACK_4XZQ_OVER_WARN);
        break;
    case RUN_FB_RESET_FINISHED:
        strcat(sc, GetString(485));
        break;
    case RUN_FB_RESET_WAIT_HANDLE:
        strcat(sc, GetString(467));
        break;
    case RUN_FB_UPS_SAVE_OK:
        strcat(sc, GetString(468));
        break;
    case ERROR_EXCEED_WIDTH:
        strcat(sc, GetString(471));
        break;
    case RUN_FB_PAUSE_WARN:
        strcat(sc, GetString(487));
        break;
    case RUN_FB_ERROR_NEEDLE:
        strcat(sc, GetString(674));
        break;
    case RUN_FB_BOARD_UNUSUAL:
        strcat(sc, GetString(767));
        break;
    case RUN_FB_ERROR_BOARD_RAISE:
        strcat(sc, GetString(755));
        break;
    case RUN_FB_ERROR_BOARD_SAFE:
        strcat(sc, GetString(756));
        break;
    case RUN_FB_ERROR_BOARD_RESET:
        strcat(sc, GetString(768));
        break;
    case RUN_FB_ERROR_HOOKWOOL:
        strcat(sc, GetString(754));
        break;
    case RUN_FB_ERROR_CLIP1_CLOSE:
        strcat(sc, GetString(757));
        break;
    case RUN_FB_ERROR_CLIP2_CLOSE:
        strcat(sc, GetString(758));
        break;
    case RUN_FB_ERROR_CLIP3_CLOSE:
        strcat(sc, GetString(759));
        break;
    case RUN_FB_ERROR_CLIP4_CLOSE:
        strcat(sc, GetString(760));
        break;
    case RUN_FB_ERROR_CLIP1_OPEN:
        strcat(sc, GetString(761));
        break;
    case RUN_FB_ERROR_CLIP2_OPEN:
        strcat(sc, GetString(762));
        break;
    case RUN_FB_ERROR_CLIP3_OPEN:
        strcat(sc, GetString(763));
        break;
    case RUN_FB_ERROR_CLIP4_OPEN:
        strcat(sc, GetString(764));
        break;
    case RUN_FB_ERROR_SCISSOR1:
        strcat(sc, GetString(765));
        break;
    case RUN_FB_ERROR_SCISSOR2:
        strcat(sc, GetString(766));
        break;
    case RUN_FB_ERROR_HOOK_OPEN:
        strcat(sc, GetString(772));
        break;
    case RUN_FB_ERROR_HOOK_CLOSE:
        strcat(sc, GetString(773));
        break;
    case RUN_FB_ERROR_BOARD_ENABLE:
        strcat(sc, GetString(778));
        break;
     case RUN_FB_RESET_YARN:
        strcat(sc, GetString(900));
        break;
    case RUN_FB_RESET_CAN:
        strcat(sc, GetString(901));
        break;
    case RUN_FB_RESET_SELECT:
        strcat(sc, GetString(902));
        break;
    case RUN_FB_RESET_DUMU:
        strcat(sc, GetString(903));
        break;
    case RUN_FB_RESET_SINK:
        strcat(sc, GetString(904));
        break;
    case RUN_FB_RESET_MAC:
        strcat(sc, GetString(905));
        break;
    case RUN_FB_RESET_ROCK:
        strcat(sc, GetString(906));
        break;
    case RUN_FB_RESET_OK:
        strcat(sc, GetString(907));
        break;
    case RUN_FB_LOCK_LINE_ERR:
        strcat(sc, GetString(920));
        break;
    default:
        strcat(sc, MW_UNKNOWN_ERROR);
        {
            char sss[32] = {0};
            sprintf(sss, "%d", errcode);
            strcat(sc, sss);
        }
        break;
    }
    WND_RUN *p = (WND_RUN*)GetWindowAdditionalData(hWnd);
    if(errcode)
    {
        if(p)
        {
            if(p->hwnd_tip != HWND_INVALID)
            {
                SetInfoText(p->hwnd_tip, sc);
                ShowWindow(p->hwnd_tip, SW_SHOWNORMAL);
            }
        }
    }
    else
    {
        if(p)
        {
            if(p->hwnd_tip > 0)
            {
                ShowWindow(p->hwnd_tip, SW_HIDE);
            }
        }
    }
}
/*
 * update warn
 */
 static void ResetRunWarn(HWND hWnd)
 {
    static ushort reset_bk = FALSE;
    static uchar bar_bk = FALSE;
    int error_code = FALSE;
    ushort state = FALSE, reset_state = FALSE;
    state = GetRunStata(g_knit_data);
    uchar bar_state = GetBarState(g_knit_data);
    if(state == SYS_STATE_RESET )
    {
        reset_state = GetRunResetState(g_knit_data);
        if(reset_bk != reset_state)
        {
            reset_bk = reset_state;
            switch(reset_state)
            {
                case RUN_RESET_YARN:
                    error_code = RUN_FB_RESET_YARN;
                break;
                case RUN_RESET_CAN:
                    error_code = RUN_FB_RESET_CAN;
                break;
                case RUN_RESET_SELECT:
                    error_code = RUN_FB_RESET_SELECT;
                break;
                case RUN_RESET_DUMU:
                    error_code = RUN_FB_RESET_DUMU;
                break;
                case RUN_RESET_SINK:
                    error_code = RUN_FB_RESET_SINK;
                break;
                case RUN_RESET_MAC:
                    error_code = RUN_FB_RESET_MAC;
                break;
                case RUN_RESET_ROCK:
                    {
                        WND_RUN *p = (WND_RUN*)GetWindowAdditionalData(hWnd);
                        error_code = RUN_FB_RESET_ROCK;
                        UpdateRunWarn(hWnd, error_code);
                        SendMessage(p->hwnd_tip, MSG_PAINT, 0, 0);
                        HWND hWndTmp = GetDlgItem(p->hwnd_tip, IDC_TIP);
                        SendMessage(hWndTmp, MSG_PAINT, 0, 0);
                        do{
                            reset_state = GetRunResetState(g_knit_data);
                        }
                        while(reset_state != RUN_RESET_OK);
                        error_code = RUN_FB_RESET_OK;
                    }
                break;
            }
            UpdateRunWarn(hWnd, error_code);
        }
    }
    if(bar_bk != bar_state)
    {
        bar_bk = bar_state;
        UpdateRunWarn(hWnd, error_code);
    }
 }
/*
 * update window
 */
static void UpdateShow(HWND hWnd)
{
   char sc[MH_FILE_NAME_MAX_LEN] = {0};
    HWND hWndTmp = 0;
    ushort last_line = GetLastKnitLine(g_knit_data);
    ushort curt_line = GetCurrentKnitLine(g_knit_data);
    if(IsAuxConKnit(g_knit_data))
    {
        curt_line = GetAuxConCurtLine(g_knit_data);
    }
    if(last_line != curt_line)
    {
        SetLastKnitLine(g_knit_data, curt_line);
        ReadConPage(hWnd, curt_line);
        FlushRunWndEfficiency(hWnd);
        FlushRunWndFinished(hWnd);
    }
    //needle
    short needle = GetRunNeedle(g_knit_data);
    sprintf(sc, "%d", needle);
    hWndTmp = GetDlgItem(hWnd, IDC_MAC_POS);
    SetWindowCaption(hWndTmp, sc);
    InvalidateRect(hWndTmp, NULL, TRUE);
    //finished cloth
    //time
    time_t curt_tm = time(NULL);
    time_t last_tm = GetSysTime(g_knit_data);
    if(curt_tm != last_tm)
    {
        SetSysTime(g_knit_data, curt_tm);
        struct tm *tm_now;
        tm_now = localtime(&curt_tm);
        sprintf(sc, "%02u/%02u/%02u %02u:%02u:%02u",
            tm_now->tm_year % 100, tm_now->tm_mon + 1, tm_now->tm_mday,
            tm_now->tm_hour, tm_now->tm_min, tm_now->tm_sec);
        hWndTmp = GetDlgItem(hWnd, ID_TIME_SET);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
        uint t = AddWorkTime(g_knit_data, curt_tm - last_tm);
        uint hour = t / 3600;
        uint minite = (t - hour * 3600) / 60;
        uint second = t % 60;
        sprintf(sc, "%02u:%02u:%02u", hour, minite, second);
        hWndTmp = GetDlgItem(hWnd, IDC_KNIT_TIME);
        SetWindowCaption(hWndTmp, sc);
        InvalidateRect(hWndTmp, NULL, TRUE);
    }
    ResetRunWarn(hWnd);
    WND_RUN *p = (WND_RUN*)GetWindowAdditionalData(hWnd);
    //error code
    int error_code = GetRunErrorCode(g_knit_data);
    if(error_code == RUN_FB_NONE || error_code == RUN_FB_QUICK_STATE
            || error_code == RUN_FB_SLOW_STATE
            || error_code == RUN_FB_STOP_STATE
            || error_code == RUN_FB_KNOT_STATE)
    {
        if(p->wnd_error)
        {
            return;
        }
    }
    p->wnd_error = FALSE;
    int handle = GetHandleState(g_knit_data);
    if(p)
    {
        if(p->error_code != error_code)
        {
            p->error_code = error_code;
            if(error_code == RUN_FB_SAFE_STOP)
            {
                if(p->hwnd_tip > 0)
                {
                    ShowWindow(p->hwnd_tip, SW_HIDE);
                }
                if(AfxMessageBox(hWnd, NULL, GetString(700)))
                {
                    AllowKnitRun(g_knit_data);
                }
            }
            else
            {
                if(error_code != RUN_FB_STOP_STATE && error_code != RUN_FB_SLOW_STATE
                        && error_code != RUN_FB_QUICK_STATE
                        && error_code != RUN_FB_RESET_FINISHED
                        && error_code != RUN_FB_RESET_WAIT
                        && error_code != RUN_FB_RESET_WAIT_HANDLE)
                {
                    AddSysLog(g_knit_data, LOG_TYPE_RUN_FEEDBACK, error_code);
                }
                if(error_code != RUN_FB_NONE && error_code !=  RUN_FB_STOP_STATE
                   && error_code != RUN_FB_SLOW_STATE
                   && error_code != RUN_FB_QUICK_STATE)
                {
                    printf("报警错误：%d\n",error_code);
                    UpdateRunWarn(hWnd, error_code);
                }
            }
        }
    }
    else if(handle == BAR_SLOWPOS || handle == BAR_QUICKPOS)
    {
        //printf("handle: %d, %d\n", handle, error_code);
        if(error_code != RUN_FB_SAFE_STOP)
        {
            UpdateRunWarn(hWnd, error_code);
        }
    }
}
/*
 *
 */
static void OnRabClose(HWND hWnd)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);
    if(data.pwnd_run)
    {
        if(data.pwnd_run->rab_close)
        {
            KnitRabOnStop(g_knit_data, 0);
            data.pwnd_run->rab_close = FALSE;
        }
        else
        {
            data.pwnd_run->rab_close = TRUE;
            data.pwnd_run->rab_open = FALSE;
            KnitRabOnStop(g_knit_data, 60);
        }
    }
}


static void OnRabOpen(HWND hWnd)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);
    if(data.pwnd_run)
    {
        if(data.pwnd_run->rab_open)
        {
            KnitRabOnStop(g_knit_data, 0);
            data.pwnd_run->rab_open = FALSE;
        }
        else
        {
            data.pwnd_run->rab_open = TRUE;
            data.pwnd_run->rab_close = FALSE;
            KnitRabOnStop(g_knit_data, -60);
        }
    }
}
/*
 *
 */
static void OnBtnCmd(HWND hWnd, int nID)
{
	switch(nID)
	{
	case ID_ESC:
	    {
	    	CreateMasterWindow(hWnd);
	    }
		break;
	case ID_HELP:
	    {
	        CreateHelpWindow(hWnd);
	    }
	    break;
	case ID_DUMU:
    case ID_DUMU1:
    case ID_DUMU2:
        CreateDensityWindow(hWnd);
	    break;
    case ID_RAB:
    case ID_MAST_ROLL:
    case ID_RAB_VALUE:
        CreateRabWindow(hWnd);
        break;
    case ID_ROLL:
    case ID_AUX_ROLL:
    case ID_ROLL_VALUE:
        CreateRollWindow(hWnd);
        break;
    case IDC_EDIT_SPEED:
    case ID_SPEED:
    case IDC_SPEED:
        {
            CreateSpeedWindow(hWnd);
        }
        break;
    case ID_YARN_STOP:
    case IDC_YARN_STOP:
        CreateYarnStopWindow(hWnd);
        break;
    case ID_SINK:
    case IDC_SINK:
        CreateSinkWindow(hWnd);
        break;
    case ID_START_POINT:
    case IDC_START_POINT:
        CreateWorkWindow(hWnd);
        break;
    case ID_RUDE:
    case IDC_RUDE:
        CreateRudeWindow(hWnd);
        break;
    case ID_CYCLE_START:
    case ID_CYCLE_END:
    case ID_CYCLE_NUM:
    case ID_CYCLE_LEFT:
    case IDC_CYCLE_START:
    case IDC_CYCLE_END:
    case IDC_CYCLE_NUM:
    case IDC_CYCLE_LEFT:
        CreateEconomyWindow(hWnd);
        break;
    case IDC_YARN:
        CreateYarnCheckWindow(hWnd);
        break;
    case ID_LEFT_YARN:
    case ID_RGHT_YARN:
        CreateYarnExchangeWindow(hWnd);
        break;
    case IDC_LINE_FINISHED:
        CreateKnitLineWindow(hWnd);
        break;
    case ID_BTN_RESET:
        if(GetRunState(g_knit_data) == STATE_STOP)
        {
            OnSwitchSpeedHigh();
            CreateResetWindow(hWnd);
        }
        break;
    case ID_BTN_HD:
        if(GetBoardEnable(g_knit_data))
        {
            WND_EXTRA_DATA data;
            data.value = GetWindowAdditionalData(hWnd);
            if(data.pwnd_run)
            {
                data.pwnd_run->wnd_error = RUN_FB_ERROR_BOARD_ENABLE;
                UpdateRunWarn(hWnd, RUN_FB_ERROR_BOARD_ENABLE);
            }
        }
        else
        {
            ushort line = GetCurrentKnitLine(g_knit_data);
            if(line == 1)
            {
                OnHangDing();
            }
            else
            {
                UpdateRunWarn(hWnd, RUN_FB_LOCK_LINE_ERR);
                HWND hWndTmp = GetDlgItem(hWnd, ID_BTN_HD);
                SetCtrlState(hWndTmp, FALSE);
                InvalidateRect(hWndTmp, NULL, TRUE);
            }
        }
        break;
    case ID_BTN_SPEED:
        {
            OnSwitchSpeed();
        }
        break;
    case ID_PIECE_LOCK:
        {
            OnLockCloth();
        }
        break;
    case ID_WARN_ENABLE:
        if(STATE_STOP == GetRunState(g_knit_data))
        {
            CreateAlarmWindow(hWnd);
        }
        break;
    case ID_YARN_UP:
        if(STATE_STOP == GetRunState(g_knit_data))
        {
            OnSwitchYarn();
        }
        break;
    case IDC_KNIT_NUM:
    case IDC_KNIT_FINISHED:
        {
            HWND hDlg = CreatePasswordDialog(hWnd);
            SetWindowCaption(hDlg, GetString(15));
            SetPasswordOtherInput(hDlg, TRUE);
            if(PasswordDoModal(hDlg))
            {
                int n = atoi(g_edit_text);
                char sc[32] = { 0 };
                sprintf(sc, "%u", n);
                HWND hWndTmp = GetDlgItem(hWnd, nID);
                if(hWndTmp != HWND_INVALID)
                {
                    SetWindowCaption(hWndTmp, sc);
                    InvalidateRect(hWndTmp, NULL, TRUE);
                }
                if(nID == IDC_KNIT_NUM)
                {
                    SetTotalCloth(g_knit_data, n);
                }
                else
                {
                    SetDoneCloth(g_knit_data, n);
                }
                SendClothNum(g_knit_data);
                int ret = WriteKnitFile(KNIT_PARAM_FILE, g_knit_data);
                if(ret)
                {
                    printf("write cloth num: %d\n", ret);
                    AddSysLog(g_knit_data, LOG_TYPE_FILE, ret);
                    AfxInfoBox(hWnd, NULL, GetString(481));
                }
                else
                {
                    MH_FILE_SYNC();
                }
            }
        }
        break;
	}
}
/*
 *
 */
static void OnKeyDown(HWND hWnd, int key)
{
    if(key == SCANCODE_CURSORBLOCKLEFT)
    {
        CreateYarnComWindow(hWnd);
    }
    else if(key == SCANCODE_CURSORBLOCKRIGHT)
    {
        CreateMacComWindow(hWnd);
    }
    else if(key == SCANCODE_CURSORBLOCKDOWN)
    {
        if(STATE_STOP == GetRunState(g_knit_data))
        {
            OnRabClose(hWnd);
        }
    }
    else if(key == SCANCODE_CURSORBLOCKUP)
    {
        if(STATE_STOP == GetRunState(g_knit_data))
        {
            OnRabOpen(hWnd);
        }
    }
    else if(key == SCANCODE_ESCAPE)
	{
		OnBtnCmd(hWnd, ID_ESC);
	}
	else if(key == SCANCODE_0)
	{
	    if(STATE_STOP == GetRunState(g_knit_data))
        {
            CreateExtentWindow(hWnd);
        }
	}
    else if(key == SCANCODE_1)
    {
        CreateDensityWindow(hWnd);
    }
    else if(key == SCANCODE_2)
    {
        CreateRabWindow(hWnd);
    }
    else if(key == SCANCODE_3)
    {
        CreateRollWindow(hWnd);
    }
	else if(key == SCANCODE_4)
	{
	    CreateSwitchWindow(hWnd);
	}
	else if(key == SCANCODE_5)
	{
	    OnBtnCmd(hWnd, ID_WARN_ENABLE);
	}
    else if(key == SCANCODE_6)
    {
        CreateYarnStopWindow(hWnd);
    }
	else if(key == SCANCODE_7)
	{
	    CreateKnitLineWindow(hWnd);
	}
	else if(key == SCANCODE_8)
	{
	    CreateYarnCheckWindow(hWnd);
	}
	else if(key == SCANCODE_9)
	{
	    CreateYarnExchangeWindow(hWnd);
	}
    else if(key == SCANCODE_A)
    {
        //
    }
    else if(key == SCANCODE_B)
    {
        //
    }
    else if(key == SCANCODE_C)
    {
        CreateEconomyWindow(hWnd);
    }
    else if(key == SCANCODE_D)
    {
        OnBtnCmd(hWnd, IDC_KNIT_NUM);
    }
    else if(key == SCANCODE_E)
    {
        if(STATE_STOP == GetRunState(g_knit_data))
        {
            CreateBoardTestWindow(hWnd);
        }
    }
	else if(key == SCANCODE_F)
	{
	    CreateStopLineWindow(hWnd);
	}
    else if(key == SCANCODE_PAGEUP)
    {
        if(STATE_STOP == GetRunState(g_knit_data))
        {
            CreateYarnFeederWindow(hWnd);
        }
    }
    else if(key == SCANCODE_MINUS)
    {
        SendMessage(GetDlgItem(hWnd, IDC_KNIT_NUM), MSG_LBUTTONDOWN, 0, 0);
    }
    else if(key == SCANCODE_F1)
    {
        OnBtnCmd(hWnd, ID_BTN_RESET);
    }
    else if(key == SCANCODE_F2)
    {
        HWND hTmp = GetDlgItem(hWnd, ID_BTN_HD);
        SetCtrlState(hTmp, !GetCtrlState(hTmp));
        InvalidateRect(hTmp, NULL, TRUE);
        OnBtnCmd(hWnd, ID_BTN_HD);
    }
    else if(key == SCANCODE_F3)
    {
        HWND hTmp = GetDlgItem(hWnd, ID_BTN_SPEED);
        SetCtrlState(hTmp, !GetCtrlState(hTmp));
        InvalidateRect(hTmp, NULL, TRUE);
        OnBtnCmd(hWnd, ID_BTN_SPEED);
    }
    else if(key == SCANCODE_F4)
    {
        HWND hTmp = GetDlgItem(hWnd, ID_PIECE_LOCK);
        SetCtrlState(hTmp, !GetCtrlState(hTmp));
        InvalidateRect(hTmp, NULL, TRUE);
        OnBtnCmd(hWnd, ID_PIECE_LOCK);
    }
    else if(key == SCANCODE_F5)
    {
        if(STATE_STOP == GetRunState(g_knit_data))
        {
            HWND hTmp = GetDlgItem(hWnd, ID_WARN_ENABLE);
            SetCtrlState(hTmp, !GetCtrlState(hTmp));
            InvalidateRect(hTmp, NULL, TRUE);
            OnBtnCmd(hWnd, ID_WARN_ENABLE);
        }
    }
    else if(key == SCANCODE_F6)
    {
        if(STATE_STOP == GetRunState(g_knit_data))
        {
            HWND hTmp = GetDlgItem(hWnd, ID_YARN_UP);
            SetCtrlState(hTmp, !GetCtrlState(hTmp));
            InvalidateRect(hTmp, NULL, TRUE);
            OnBtnCmd(hWnd, ID_YARN_UP);
        }
    }
    else if(key == SCANCODE_F7)
    {
        OnBtnCmd(hWnd, ID_HELP);
    }
    else if(key == SCANCODE_F8)
    {
        CreateDumuComWindow(hWnd);
    }
    /*else if(key == SCANCODE_S)
    {
        OnReset(hWnd, 1, 0);
    }*/
    else if(key == SCANCODE_T)
    {
        PostMessage(hWnd, MSG_CLOSE, 0, 0);
    }
    else if(key == SCANCODE_PERIOD)
    {
        if(STATE_STOP == GetRunState(g_knit_data))
        {
            CreateVerWindow(hWnd);
        }
    }
    else if(key == SCANCODE_REMOVE || key == SCANCODE_BACKSPACE)
    {
        ushort nID = GetDlgCtrlID(GetFocusChild(hWnd));
        if(nID == IDC_KNIT_FINISHED)
        {
            HWND hTmp = GetDlgItem(hWnd, nID);
            SetWindowCaption(hTmp, "0");
            InvalidateRect(hTmp, NULL, TRUE);
            SetDoneCloth(g_knit_data, 0);
        }
    }
}
/*
 *
 */
static void DisableCtrl(HWND hWnd)
{
    WND_EXTRA_DATA data;
    data.value = GetWindowAdditionalData(hWnd);
    HWND hTmp = GetDlgItem(hWnd, ID_YARN_UP);
    if(STATE_STOP == GetRunState(g_knit_data))
    {
        EnableWindow(hTmp, TRUE);
    }
    else
    {
        EnableWindow(hTmp, FALSE);
        if(data.pwnd_run)
        {
            data.pwnd_run->rab_close = FALSE;
            data.pwnd_run->rab_open = FALSE;
        }
    }
}
/*
 *
 */
static int RunWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
	switch(message)
    {
    case MSG_CREATE:
        {
            CreateRunInterface(hWnd);
        }
        break;
    case MSG_PAINT:
        {
            HDC hdc = GetClientDC(hWnd);
            SetPenColor(hdc, COLOR_HQ_GRAY(hdc));
            Rectangle(hdc, FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + 4,
                FLW_CAPTION_TOP - 1,
                FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + YARN_CAPTION_WIDTH + 6,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 3);
            MoveTo(hdc, FLW_CAPTION_LEFT + YARN_CAPTION_WIDTH + 5, FLW_CAPTION_TOP);
            LineTo(hdc, FLW_CAPTION_LEFT + YARN_CAPTION_WIDTH + 5, FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 3);
            Rectangle(hdc, FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + 4,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 6 - 1,
                FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + YARN_CAPTION_WIDTH + 6,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 9);
            MoveTo(hdc, FLW_CAPTION_LEFT + YARN_CAPTION_WIDTH + 5, FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 6);
            LineTo(hdc, FLW_CAPTION_LEFT + YARN_CAPTION_WIDTH + 5, FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 9);
            Rectangle(hdc, CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH - YARN_CAPTION_WIDTH - 7,
                FLW_CAPTION_TOP - 1,
                CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH - 5,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 3);
            MoveTo(hdc, CX_SCREEN - CX_EDGE_RIGHT - YARN_CAPTION_WIDTH - 6, FLW_CAPTION_TOP);
            LineTo(hdc, CX_SCREEN - CX_EDGE_RIGHT - YARN_CAPTION_WIDTH - 6, FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 3);
            Rectangle(hdc, CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH - YARN_CAPTION_WIDTH - 7,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 6 - 1,
                CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH - 5,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 9);
            MoveTo(hdc, CX_SCREEN - CX_EDGE_RIGHT - YARN_CAPTION_WIDTH - 6, FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 6);
            LineTo(hdc, CX_SCREEN - CX_EDGE_RIGHT - YARN_CAPTION_WIDTH - 6, FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 9);
            //left edit dumu
            Rectangle(hdc, FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + YARN_CAPTION_WIDTH + 19,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT,
                FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH * 2 + YARN_CAPTION_WIDTH + 20,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 2 + 1);
            Rectangle(hdc, FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH * 2 + YARN_CAPTION_WIDTH + 29,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT,
                FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH * 3 + YARN_CAPTION_WIDTH + 30,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 2 + 1);
            Rectangle(hdc, FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH + YARN_CAPTION_WIDTH + 19,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7 - 2,
                FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH * 2 + YARN_CAPTION_WIDTH + 20,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 8 - 1);
            Rectangle(hdc, FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH * 2 + YARN_CAPTION_WIDTH + 29,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7 - 2,
                FLW_CAPTION_LEFT + FLW_CAPTION_WIDTH * 3 + YARN_CAPTION_WIDTH + 30,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 8 - 1);
            //right dumu edit
            Rectangle(hdc, CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 2 - YARN_CAPTION_WIDTH - 21,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT,
                CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH - YARN_CAPTION_WIDTH - 20,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 2 + 1);
            Rectangle(hdc, CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 3 - YARN_CAPTION_WIDTH - 31,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT,
                CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 2 - YARN_CAPTION_WIDTH - 30,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 2 + 1);
            Rectangle(hdc, CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 2 - YARN_CAPTION_WIDTH - 21,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7 - 2,
                CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH - YARN_CAPTION_WIDTH - 20,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 8 - 1);
            Rectangle(hdc, CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 3 - YARN_CAPTION_WIDTH - 31,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 7 - 2,
                CX_SCREEN - CX_EDGE_RIGHT - FLW_CAPTION_WIDTH * 2 - YARN_CAPTION_WIDTH - 30,
                FLW_CAPTION_TOP + FLW_CAPTION_HEIGHT * 8 - 1);
            ReleaseDC(hdc);
             uchar net_state = GetNetworkState(g_knit_data);
            if(net_state == RUN_FB_NETMESSAGE_WARN)
            {
                int code = RUN_FB_NETMESSAGE_WARN;
                UpdateRunWarn(hWnd, code);
                SetNetworkState(g_knit_data, RUN_FB_ERROR_NET);
            }
        }
        break;
    case MSG_CLOSE:
        {
            KillTimer(hWnd, TIMER_ID_RUN);
            DestroyMainWindow(hWnd);
            //MainWindowCleanup(hWnd);
            PostQuitMessage(hWnd);
        }
        return 0;
    case MSG_DESTROY:
        {
            ShowWindow(hWnd, SW_HIDE);
            DestroyAllControls(hWnd);
            WND_RUN *p = (WND_RUN*)GetWindowAdditionalData(hWnd);
            if(p)
            {
                if(p->hwnd_tip != HWND_INVALID)
                {
                    PostMessage(p->hwnd_tip, MSG_CLOSE, 0, 0);
                }
                free(p);
            }
            EndKnitRun(g_knit_data);
        }
        return 0;
    case MSG_KEYDOWN:
        {
            OnKeyDown(hWnd, wParam);
        }
        return 0;
    case MSG_CHAR:
    	return 0;
    case MSG_ERASEBKGND:
        {
            DrawBitmapBkGnd(hWnd, (RECT*)lParam, &g_bmp[BMP_RUN]);
        }
    	return 0;
    case MSG_COMMAND:
        {
        	OnBtnCmd(hWnd, LOWORD(wParam));
        }
    	return 0;
    case MSG_TIMER:
        {
            uint id = wParam;
            DisableCtrl(hWnd);
            if(id == TIMER_ID_RUN)
            {
                UpdateShow(hWnd);
            }
        }
        break;
    case MSG_GOTO_LINE:
        {
            ushort line = wParam;
            if(line > 0 && line <= GetTotalKnitPage(g_knit_data))
            {
                OnReset(hWnd, line, RESET_GOTO);
            }
        }
        break;
    case MSG_LBUTTONDOWN:
        {
            WND_EXTRA_DATA data;
            data.value = GetWindowAdditionalData(hWnd);
            if(data.pwnd_run)
            {
                if(data.pwnd_run->hwnd_tip > 0)
                {
                    ShowWindow(data.pwnd_run->hwnd_tip, SW_HIDE);
                }
            }
        }
        break;
    case MSG_SETFOCUS:
        if(g_hwnd_run > 0)
        {
            ShowRunWindow(hWnd);
        }
        break;
    case MSG_KILLFOCUS:
        {
            //
        }
        break;
    case MSG_RESET:
        {
            ushort n = wParam;
            int type = lParam;
            if(n > 0 && n <= GetTotalKnitPage(g_knit_data))
            {
                if(GetRunState(g_knit_data) == STATE_STOP)
                {
                    OnReset(hWnd, n, type);
                }
            }
        }
        break;
    }
    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
/*
 *
 */
void ShowRunWindow(HWND hWnd)
{
    if(SwitchToKnitState(g_knit_data, TRUE) < 0)
    {
        printf("error %s,      %d, send work param error\n", __FILE__, __LINE__);
    }
    ShowWindow(hWnd, SW_SHOWNORMAL);
    uchar need_do = GetWhichNeedDo(g_knit_data);
    if(need_do == NEED_DO_RESET_START)
    {
        if(GetRunState(g_knit_data) == STATE_STOP)
        {
            OnReset(hWnd, GetKnitStartLine(g_knit_data), 0);
        }
    }
    SetWhichNeedDo(g_knit_data, 0);
}
/*
 *
 */
HWND CreateRunWindow(HWND hHosting)
{
    WND_RUN *p = calloc(1, sizeof(WND_RUN));
    MAINWINCREATE CreateInfo;
    CreateInfo.dwStyle = WS_VISIBLE;
    CreateInfo.dwExStyle = WS_EX_NONE;
    CreateInfo.spCaption = MW_RUN_TITLE_CAPTION;
    CreateInfo.hMenu = 0;
    CreateInfo.hCursor = GetSystemCursor(0);
    CreateInfo.hIcon = 0;
    CreateInfo.MainWindowProc = RunWinProc;
    CreateInfo.lx = 0;
    CreateInfo.ty = 0;
    CreateInfo.rx = CX_SCREEN;
    CreateInfo.by = CY_SCREEN;
    CreateInfo.iBkColor = COLOR_lightwhite;
    CreateInfo.dwAddData = (int)p;
    CreateInfo.hHosting = hHosting;
    HWND hWnd = CreateMainWindow(&CreateInfo);
    if(hWnd != HWND_INVALID)
    {
        uchar need_do = GetWhichNeedDo(g_knit_data);
        if(need_do == NEED_DO_GOON_KNIT)
        {
            /*等待继续编织的数据发完再读反馈*/
            ForbidFeedback(g_knit_data, TRUE);
        }
        SwitchToKnitState(g_knit_data, TRUE);
    	ShowWindow(hWnd, SW_SHOWNORMAL);
    	SetTimer(hWnd, TIMER_ID_RUN, 5);
    	p->hwnd_tip = CreateInfoDialog(hWnd, INFO_BMP_LEN);
    	if(p->hwnd_tip != HWND_INVALID)
    	{
    	    SetInfoModal(p->hwnd_tip, FALSE);
    	}
    	if(need_do == NEED_DO_RESET_START)
        {
            if(GetRunState(g_knit_data) == STATE_STOP)
            {
                OnReset(hWnd, GetKnitStartLine(g_knit_data), 0);
            }
        }
        else if(need_do == NEED_DO_GOON_KNIT)
        {
            if(GetRunState(g_knit_data) == STATE_STOP)
            {
                if(RestoreKnitAfterPowerOn(g_knit_data))
                {
                    p->wnd_error = RUN_FB_NETMESSAGE_WARN;
                    UpdateRunWarn(hWnd, p->wnd_error);
                }
                else
                {
                    FlushRunWndCycle(hWnd, GetCurrentKnitLine(g_knit_data));
                }
            }
            else
            {
                printf("Warnning %s: %d\n", __FILE__, __LINE__);
            }
            ForbidFeedback(g_knit_data, FALSE);
        }
        SetWhichNeedDo(g_knit_data, 0);
    }
    return hWnd;
}
